package com.zlcx.tz.live.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * @author anjl
 * 计时学习自习室所有用户信息
 */

@Data
@Builder
@Entity(name = "tz_time_learn_room_users")
@NoArgsConstructor
@AllArgsConstructor
@JsonSerialize
@DynamicUpdate
@DynamicInsert
public class TimeLearnRoomUsersDO implements Serializable {

    public static final String FIELD_CREATE_TIME = "createTime";
    public static final String FIELD_ID = "id";
    public static final String FIELD_ROOM_ID = "roomId";

    private static final long serialVersionUID = 3307672338986942282L;
    @Id
    @GeneratedValue
    private Long id;

    /**
     * 房间id
     */
    private Long roomId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 进入房间时间
     */
    private Date joinTime;

    /**
     * @see TimeLearnRoomUserState
     * 用户状态
     */
    private String state;

    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public enum TimeLearnRoomUserState {

        FREE_TIME("空闲"),
        LEARNING_TIME("学习中"),
        ;

        private String desc;

        TimeLearnRoomUserState(String tips) {
            this.desc = tips;
        }
    }

}